package org.jeecg.modules.asset.chartInfo.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.asset.chartInfo.entity.Chartinfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @Description: ChartInfo
 * @Author: jeecg-boot
 * @Date:   2020-03-30
 * @Version: V1.0
 */
public interface ChartinfoMapper extends BaseMapper<Chartinfo> {

    //返回所有的经营项目
    @Select("SELECT FareItem from ChartInfo WHERE  len(FareItem) > 0 GROUP BY FareItem")
    List<String> findAllFareItem();

    @Select("SELECT * from ChartInfo WHERE  guid = #{chartguid} ")
    Chartinfo getByGuid(String chartguid);

    @Update("update ChartInfo set IsHistory = null,state = '空置' where guid = #{chartguid} ")
    void updateIsHistoryByGuid(String chartguid);

    void updateByGuid(Chartinfo chartinfo); //此处sql写在xml中

    @Select("select * from Chartinfo where RoomAddress like '%' + #{str} + '%' ")
    IPage<Chartinfo> getByFuzzy(@RequestParam("page") Page<Chartinfo> page, @RequestParam("str") String str);
}
